import { FormInstance } from 'antd';
import React from 'react';
import { useState } from 'react';

const useBseGeneraHook = () => {
  const [open, setOpen] = useState<boolean>(false);
  const [edit, setEdit] = useState<boolean>(false);
  const [rowId, setRowId] = useState<string | number | undefined>();
  const [isPassed, setIsPassed] = useState<boolean>(false);
  const formRef = React.useRef<FormInstance>(null);

  const openModal = () => {
    setOpen(true);
  };

  const closeModal = () => {
    setOpen(false);
  };

  const addModal = () => {
    setEdit(true);
  };

  const editModal = () => {
    setEdit(false);
  };

  const rowIdSelect = (id: string | number) => {
    setRowId(id);
  };

  const isPassedModal = () => {
    setIsPassed(true);
  };

  return {
    open,
    edit,
    rowId,
    isPassed,
    rowIdSelect,
    isPassedModal,
    openModal,
    closeModal,
    addModal,
    editModal,
    formRef,
  };
};

export default useBseGeneraHook;
